home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.pl1,comp.lang.c
- Subject: Re: PL/I and C
- Date: 26 Feb 1996 13:16:15 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4gt0tv$826@solutions.solon.com>
- References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <4grhtv$s31@goanna.cs.rmit.EDU.AU>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4grhtv$s31@goanna.cs.rmit.EDU.AU>,
- ++ robin <rav@goanna.cs.rmit.EDU.AU> wrote:
- >---The basic operations of string-handling are done somewhat
- >clumsily in C -- catenation is a simple infix operation
- >in PL/I, but you must use a function in C, and then it
- >catentates the second operand to the first. Nothing like
- >c = d || e;
- >(And what happens when, in strcat(s1, s2), the sum of the lengths
- >of s1 and s2 exceeds the declaration for s1?!?!?
-
- Then you invoke undefined behavior, and your code was illegal. :)
-
- Yes, C's string handling is primitive. It also has no hidden overhead.
-
- >---again, for comparison, IF s1 > s2 THEN . . . becomes
- >strcmp(s1, s2) . . . which yields neg, 0, or pos . . .
- >which leads to IF strcmp(s1, s2) > 0 . . .
- >which is scarcely intuitive [shades of the arcane FORTRAN
- >arithmetic IF].
-
- I would kill for arithmetic if, simply because I frequently want to do
- one of three things bsed on the sign of an expression.
-
- Once again, C has no hidden overhead, but has primitive functions. And?
-
- > I'd agree with the statement about built-in functions.
- >PL/I for AIX and OS/2 now have BIFs for searching for specific
- >characters (SEARCH) either from the right or from the left,
- >searching for the absence of specififc characters (VERIFY)
- >from the right or left.
-
- strchr, strrchr, strspn, strcspn, strpbrk.
-
- > Furthermore INDEX, SEARCH, SEARCHR, VERIFY and VERIFYR
- >can start the search at any specified position (the three-
- >argument versions).
-
- Same functions in C, you just use (s + 2) to start 2 positions in. :)
-
- > There are several functions for centering text, & trimming
- >given characters from either or both ends of a string.
-
- sprintf.
-
- > And what happens when you actually w*a*n*t a zero byte in your
- >C character string?
-
- All C character strings have a zero byte in them. It's at the end.
- (But it *is* a part of the string, so far as I can tell.)
-
- If you want an object which has characters possibly including NUL bytes,
- but is otherwise like a string, feel free to make one; it's trivial.
- It's just more expensive to run.
-
- This is silly, though. C is a low-level language by modern standards.
- So? It's a design call. You choose a language that meets your needs. C
- meets my needs because it's available for the machines I want to use.
-
- Let's try to keep the inter-language flame wars at a minimum, and if nothing
- else, let's try to keep it so that only people who know C very well and are
- comfortable with the whole library are discussing C's merits, and ditto
- for PL/I. I certainly don't have the qualifications to bash PL/I, and I doubt
- you have the qualifications to bash C. :)
-
- (I can bash C, I just don't really want to.)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-